********************************************************************************
* Balyuk, Berger, and Hackney (2024)                                           *
* "What is Fueling FinTech Lending? The Role of Banking Market Structure"      *
* The Review of Corporate Financial Studies                                    *
********************************************************************************

clear all
clear matrix

	set scheme s1mono
	grstyle init
	grstyle yesno draw_major_vgrid yes
	grstyle set plain, nobox

************************   Figure 3, Panel A   *********************************

* heat map *
	
	use "$code\DATA_usdbcounty.dta", clear
	sort fips

	joinby fips using "$code\DATA_heatmap_2018_P.dta", unm(master)
	drop _m

	drop if STATEFP=="72" | STATEFP=="78" | STATEFP=="60" | STATEFP=="66" | STATEFP=="69"	
	
	replace Ysb1_P=0 if Ysb1_P==.
	replace Ysb1_P=round(Ysb1_P,0.001)
	
	spmap Ysb1_P using "$code\DATA_xy_coor_county.dta", ///
				id(id) fcolor(Blues2) legend(pos(4)) ///
				title("Panel A: FinTech Loan Vol/Pop - Prosper Marketplace")
	graph export "$code\Figure_3_P.png", replace
	
************************   Figure 3, Panel B   *********************************	

clear all
clear matrix

* heat map - PSEUDO data *
	
	use "$code\DATA_usdbcounty.dta", clear
	rename fips fips_pseudo
	sort fips_pseudo

	joinby fips_pseudo using "$code\DATA_heatmap_2018_FC_pseudo.dta", unm(master)
	drop _m

	drop if STATEFP=="72" | STATEFP=="78" | STATEFP=="60" | STATEFP=="66" | STATEFP=="69"	
	
	replace Ysb1_FC=0 if Ysb1_FC==.
	replace Ysb1_FC=round(Ysb1_FC,0.001)
	
	spmap Ysb1_FC using "$code\DATA_xy_coor_county.dta", ///
				id(id) fcolor(Blues2) legend(pos(4)) ///
				title("Panel B: FinTech Loan Vol/Pop - Funding Circle")
	graph export "$code\Figure_3_FC.png", replace			

